package com.eric.windows.event;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;

/**
 * <h3>Description</h3>
 * TODO
 * <h3>Author</h3> Eric
 * <h3>Date</h3> 2017/8/3 15:56
 * <h3>Copyright</h3> Copyright (c)2017 Shenzhen TLIT  Co., Ltd. Inc. All rights reserved.
 */
public class DrawCirlceView extends View {

    private float currentX = 50;
    private float currentY = 50;
    private Context context;
    Paint paint = new Paint();

    public DrawCirlceView(Context context) {
        super(context);
        this.context = context;
        setFocusable(true);
    }

    public DrawCirlceView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        this.context = context;
    }

    public DrawCirlceView(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
    }

    public DrawCirlceView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.context = context;
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        paint.setColor(Color.RED);
//        canvas.drawBitmap(BitmapFactory.decodeResource(
//                context.getResources(),R.mipmap.ic_plane),currentX,currentY,paint);
        canvas.drawCircle(currentX,currentY,50,paint);

    }


    @Override
    public boolean onTouchEvent(MotionEvent event) {
        this.currentX = event.getX();
        this.currentY = event.getY();
        invalidate();
        return true;
    }

    public float getCurrentY() {
        return currentY;
    }

    public float getCurrentX() {
        return currentX;
    }

    public void setCurrentX(float currentX) {
        this.currentX = currentX;
    }

    public void setCurrentY(float currentY) {
        this.currentY = currentY;
    }
}
